﻿Public Class TMyUser
    Implements System.IDisposable

    Private _Query As New TMyQuery
    Friend _UserName As String
    Friend _Host As String

    Private _GlobalPrivs As TMyGlobalPrivileges
    Private _TablePrivs As TMyTablePrivilegesList
    Private _ColumnPrivs As TMyColumnPrivilegesList
    Private _DatabasePrivs As TMyDatabasePrivilegesList
    Private _ProcPrivs As TMyProcPrivilegesList

    Friend ReadOnly Property Query() As TMyQuery
        Get
            Return _Query
        End Get
    End Property

    Public Sub Refresh()
        _GlobalPrivs.Refresh()
        _TablePrivs.Refresh()
        _ColumnPrivs.Refresh()
        _DatabasePrivs.Refresh()
        _ProcPrivs.Refresh()
    End Sub

    Public Sub New(ByVal AConnection As TMySession)
        _Query.Session = AConnection
        _GlobalPrivs = New TMyGlobalPrivileges(Me)
        _TablePrivs = New TMyTablePrivilegesList(Me)
        _ColumnPrivs = New TMyColumnPrivilegesList(Me)
        _DatabasePrivs = New TMyDatabasePrivilegesList(Me)
        _ProcPrivs = New TMyProcPrivilegesList(Me)
    End Sub
    Public ReadOnly Property GlobalPrivs() As TMyGlobalPrivileges
        Get
            Return _GlobalPrivs
        End Get
    End Property
    Public ReadOnly Property TablePrivs() As TMyTablePrivilegesList
        Get
            Return _TablePrivs
        End Get
    End Property
    Public ReadOnly Property ColumnPrivs() As TMyColumnPrivilegesList
        Get
            Return _ColumnPrivs
        End Get
    End Property
    Public ReadOnly Property DatabasePrivs() As TMyDatabasePrivilegesList
        Get
            Return _DatabasePrivs
        End Get
    End Property
    Public ReadOnly Property ProcPrivs() As TMyProcPrivilegesList
        Get
            Return _ProcPrivs
        End Get
    End Property
    Public ReadOnly Property UserName() As String
        Get
            Return _UserName
        End Get
    End Property
    Public ReadOnly Property Host() As String
        Get
            Return _Host
        End Get
    End Property

    Private disposedValue As Boolean = False        ' 重複する呼び出しを検出するには

    ' IDisposable
    Protected Overridable Sub Dispose(ByVal disposing As Boolean)
        If Not Me.disposedValue Then
            If disposing Then
                ' TODO: 他の状態を解放します (マネージ オブジェクト)。
            End If
            _GlobalPrivs.Dispose()
            _TablePrivs.Dispose()
            _ColumnPrivs.Dispose()
            _DatabasePrivs.Dispose()
            _ProcPrivs.Dispose()
            ' TODO: ユーザー独自の状態を解放します (アンマネージ オブジェクト)。
            ' TODO: 大きなフィールドを null に設定します。
        End If
        Me.disposedValue = True
    End Sub

#Region " IDisposable Support "
    ' このコードは、破棄可能なパターンを正しく実装できるように Visual Basic によって追加されました。
    Public Sub Dispose() Implements IDisposable.Dispose
        ' このコードを変更しないでください。クリーンアップ コードを上の Dispose(ByVal disposing As Boolean) に記述します。
        Dispose(True)
        GC.SuppressFinalize(Me)
    End Sub
#End Region

End Class
